package com.mask.roll.common.controller;

import com.mask.roll.common.code.SystemEnums;
import com.mask.roll.common.constant.RollConstants;
import com.mask.roll.common.exception.RollException;
import com.mask.roll.common.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author hx
 * @since 2021/10/29 9:03 上午
 */
@Slf4j
public class BaseController {

    public static String getUserWrapper(HttpServletRequest request) {
        if (JwtUtils.checkToken(request)) {
            return JwtUtils.getMemberIdByJwtToken(request);
        }else {
            throw new RollException(SystemEnums.NOT_LOGIN.getCode(),
                    RollConstants.ERROR,SystemEnums.NOT_LOGIN.getMessage());
        }
    }
}
